<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jquery-POST请求</title>
    <style>
        #result {
            width: 300px;
            height: 100px;
            border: 1px solid #cccccc;
        }
    </style>
</head>

<body>
    <table>
        <tr>
            <td>城市Id：</td>
            <td>
                <input id="cid" type="text">
            </td>
        </tr>
        <tr>
            <td>城市名称：</td>
            <td>
                <input id="cname" type="text">
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <button id="btn">添加</button>
            </td>
        </tr>
    </table>
    <div id="result"></div>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <script>
        $("#btn").click(function(){
            $.post('http://localhost:3000/addCity', 
                { cid:$('#cid').val(), cname: $('#cname').val()},
                function (res) {
                   $('#result').html(res)
            })
        })
    </script>
</body>

</html>